{extend name="public/world"}
{block name="style"}
<style type="text/css">
</style>
{/block}
{block name="container"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-form" lay-filter="formSearch">
                <div class="layui-field-box" style="padding:0;">
                    <div class="layui-form-item" style="margin-bottom:0">
                        <div class="layui-inline my-search">
                            <div class="layui-input-inline">
                                <input type="text" name="start_at" class="layui-input" id="laydate-start" placeholder="统计月份" lay-key="1" value="">
                            </div>
                            <div class="layui-input-inline">
                                <select name="roleid" lay-filter="roleid">
                                    <option value="">职位部门</option>
                                    {volist name="groups" id="group"}
                                    <option value="{$key}">{$group}</option>
                                    {/volist}
                                </select>
                            </div>
                            <div class="layui-input-inline" style="width: 170px;">
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-primary" title="清除条件" style="padding: 0 8px;" lay-submit lay-filter="reset"><i class="layui-icon" style="color:#009688;">&#xe640;</i></button>
                                <button type="button" class="layui-btn layui-btn-sm layui-btn-radius" lay-submit lay-filter="search">搜索</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/html" id="barDemo">

</script>
<script>
    layui.use(['form','table','laydate'], function() {
        var $ = layui.jquery
            , form = layui.form
            , table = layui.table
            , laydate = layui.laydate;
        //开始日期
        var insStart = laydate.render({
            elem: '#laydate-start'
            ,type: 'month'
            ,max:'nowTime'
            ,value: new Date()
            ,ready: function(date){
                $('#layui-laydate1').on('click','ul.laydate-month-list li', function() {
                    $(this).hasClass('.laydate-disabled') || $('#layui-laydate1').find('.laydate-btns-confirm').click();
                });
            }
            ,done: function(value, date){
                setTimeout(function(){
                    $('#seachSub').click();
                }, 100);
            }
        });
        form.on('submit(search)', function(){
            AtableIns.reload({
                where: form.val("formSearch"),
                page: {curr: 1}
            });
        });
        //头工具栏事件
        form.on('submit(reset)', function(){
            var searchs = form.val("formSearch");
            for (var i in searchs) {
                searchs[i] = '';
            }
            form.val("formSearch", searchs);
            AtableIns.reload({
                where: null,
                page: {curr: 1}
            });
        });

        var AtableIns = table.render({
            elem: '#dataTable'
            ,url: "{:url('/projects.Index/rate')}" //数据接口
            ,where: form.val("formSearch")
            ,page: false //开启分页
            ,skin: 'row'
            ,even: true
            ,text: {
                none : '暂无统计'
            }
            ,toolbar: '#toolbar'
            ,defaultToolbar: false
            ,cols: [[ //表头
                {field: 'real_name', width: 120, title: '姓名', fixed: 'left'}
                ,{field: 'group', title: '部门职位'}
                ,{field: 'rate_total', width: 110, title: '积分总额'}
                ,{field: 'rate_work', width: 110, title: '工时积分'}
                ,{field: 'rate_audit', width: 110, title: '评测积分'}
                ,{field: 'rate_punish', width: 110, title: '处罚积分', templet: function(d){
                    return d.rate_punish>0 ? '-' + d.rate_punish : d.rate_punish;
                }}
            ]]
        });
    });
</script>
{/block}